package com.pearadmin.pro.modules.fnc.service.impl;

import java.util.List;
import java.util.ArrayList;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pearadmin.pro.common.web.base.page.PageResponse;
import com.pearadmin.pro.common.web.base.page.Pageable;

import com.pearadmin.pro.modules.fnc.domain.ScrmFncInfo;
import com.pearadmin.pro.modules.fnc.domain.ScrmFncRecpay;
import com.pearadmin.pro.modules.fnc.param.ScrmFncRecpayRequest;
import com.pearadmin.pro.modules.fnc.repository.ScrmFncRecpayRepository;
import com.pearadmin.pro.modules.fnc.service.ScrmFncRecpayService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;


/**
 * 财务-收付款Service业务层处理
 *
 * @author chenjian
 * @date 2021-09-25
 */
@Service
public class ScrmFncRecpayServiceImpl extends ServiceImpl<ScrmFncRecpayRepository, ScrmFncRecpay> implements ScrmFncRecpayService
{
    @Resource
    private ScrmFncRecpayRepository scrmFncRecpayRepository;

    /**
     * 查询财务-收付款
     * @param request
     * @return 财务-收付款 分页集合
     * */
    @Override
    public PageResponse<ScrmFncRecpay> page(ScrmFncRecpayRequest request)
    {
        LambdaQueryWrapper<ScrmFncRecpay> query = new LambdaQueryWrapper<ScrmFncRecpay>();
        query.eq(ObjectUtil.isNotEmpty(request.getRecName()), ScrmFncRecpay::getRecName, request.getRecName());
        query.eq(ObjectUtil.isNotEmpty(request.getPayName()), ScrmFncRecpay::getPayName, request.getPayName());
        query.eq(ObjectUtil.isNotEmpty(request.getTradeType()), ScrmFncRecpay::getTradeType, request.getTradeType());
        query.eq(ObjectUtil.isNotEmpty(request.getCurrency()), ScrmFncRecpay::getCurrency, request.getCurrency());
        query.eq(ObjectUtil.isNotEmpty(request.getPaymentMethod()), ScrmFncRecpay::getPaymentMethod, request.getPaymentMethod());
        query.eq(ObjectUtil.isNotEmpty(request.getProduceWay()), ScrmFncRecpay::getProduceWay, request.getProduceWay());
        query.eq(ObjectUtil.isNotEmpty(request.getCheckStatus()), ScrmFncRecpay::getCheckStatus, request.getCheckStatus());
        query.eq(ObjectUtil.isNotEmpty(request.getBillSrc()), ScrmFncRecpay::getBillSrc, request.getBillSrc());
        query.gt(ObjectUtil.isNotEmpty(request.getBgeinTime()),  ScrmFncRecpay::getCreateTime, request.getBgeinTime());
        query.lt(ObjectUtil.isNotEmpty(request.getEndTime()),  ScrmFncRecpay::getCreateTime, request.getEndTime());
        return Pageable.of(request,(()->  scrmFncRecpayRepository.selectList(query)));
    }
    /**
     * 保存财务-收付款
     *
     * @param id 财务-收付款ID
     * @return 财务-收付款
     */
    @Override
    public boolean saveOrUpdate(ScrmFncRecpay request) {
        return save(request);
    }

    /**
     * 查询财务-收付款
     *
     * @param id 财务-收付款ID
     * @return 财务-收付款
     */
    @Override
    public ScrmFncRecpay selectScrmFncRecpayById(Long id)
    {
        return scrmFncRecpayRepository.selectById(id);
    }

}
